home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol C-14 / Vol C-14.iso / games / smashing.swf / scripts / frame_58 / DoAction.as
Text File  |  2012-04-23  |  4KB  |  156 lines

  1. function padActions()
  2. {
  3.    if(Key.isDown(37) or Key.isDown(39))
  4.    {
  5.       Mouse.hide();
  6.       if(Key.isDown(39) && !Key.isDown(37))
  7.       {
  8.          usingKeyboard = true;
  9.          pad.TargetX += padKeyJump;
  10.          padSpeed++;
  11.       }
  12.       if(!Key.isDown(39) && Key.isDown(37))
  13.       {
  14.          usingKeyboard = true;
  15.          pad.TargetX -= padKeyJump;
  16.          padSpeed--;
  17.       }
  18.       if(!Key.isDown(39) && !Key.isDown(37))
  19.       {
  20.          padSpeed = 0;
  21.       }
  22.       tempXMouse = int(_xmouse);
  23.    }
  24.    else if(tempXMouse != int(_xmouse))
  25.    {
  26.       Mouse.show();
  27.       if(leftWall >= int(_xmouse))
  28.       {
  29.          pad.TargetX = leftWall;
  30.       }
  31.       else if(int(_xmouse) >= rightWall)
  32.       {
  33.          pad.TargetX = rightWall;
  34.       }
  35.       else
  36.       {
  37.          pad.TargetX = int(_xmouse);
  38.       }
  39.       padSpeed = int(pad.TargetX - pad._x);
  40.    }
  41.    if(spawnNewBall)
  42.    {
  43.       spawnNewBall = false;
  44.       if(ballsActive < 1 && readyToShootBall == true)
  45.       {
  46.          pad.left.ballStuck._visible = false;
  47.          pad.right.ballStuck._visible = false;
  48.          generateBall(true,pad._x,pad._y - pad._height);
  49.       }
  50.    }
  51.    if(leftWall >= pad.TargetX)
  52.    {
  53.       pad.TargetX = leftWall;
  54.    }
  55.    else if(pad.TargetX >= rightWall)
  56.    {
  57.       pad.TargetX = rightWall;
  58.    }
  59.    if(pad.left.gotoState == "firepower")
  60.    {
  61.       if((Key.isDown(32) or mouseButtonDown) && bulletsFired < 3)
  62.       {
  63.          if(weaponFired)
  64.          {
  65.             sndChargeUp.start(0,0);
  66.          }
  67.          spaceKeyRelesed = false;
  68.          mouseButtonDown = true;
  69.          usingKeyboard = true;
  70.          weaponFired = false;
  71.          fireAmount++;
  72.          if(pad.left.weapon._totalframes >= fireAmount)
  73.          {
  74.             pad.left.weapon.gotoAndStop(fireAmount);
  75.             pad.right.weapon.gotoAndStop(fireAmount);
  76.          }
  77.          weaponActivated = true;
  78.       }
  79.       else if((!spaceKeyRelesed or !mouseButtonDown) && weaponActivated && !weaponFired)
  80.       {
  81.          spaceKeyRelesed = true;
  82.          weaponFired = true;
  83.          if(1 < pad.left.weapon._currentframe && bulletsFired < 1)
  84.          {
  85.             sndChargeUp.stop();
  86.             bulletsFired++;
  87.             clipCounter++;
  88.             attachMovie("mcBullet","mcBullet" + clipCounter,clipCounter);
  89.             this["mcBullet" + _root.clipCounter]._x = pad._x;
  90.             this["mcBullet" + _root.clipCounter]._y = pad._y - pad._height;
  91.             bulletSize = this["mcBullet" + _root.clipCounter]._xscale + pad.left.weapon._currentframe * 4;
  92.             this["mcBullet" + _root.clipCounter]._xscale = bulletSize;
  93.             this["mcBullet" + _root.clipCounter]._yscale = bulletSize;
  94.          }
  95.          fireAmount = 1;
  96.          pad.left.weapon.gotoAndStop(fireAmount);
  97.          pad.right.weapon.gotoAndStop(fireAmount);
  98.       }
  99.    }
  100.    if(padSpeed != 0)
  101.    {
  102.       if(usingKeyboard)
  103.       {
  104.          pad._x += (pad.TargetX - pad._x) / 1.5;
  105.       }
  106.       else
  107.       {
  108.          pad._x = pad.TargetX;
  109.       }
  110.    }
  111. }
  112. function ballHitPad(ball)
  113. {
  114.    if(pad.left.edge.hitTest(ball.testMoveX,ball.testMoveY,true))
  115.    {
  116.       sndBallHitPadEdge.start(0,0);
  117.       _root.pad.left.edgeGlass.gotoAndPlay(1);
  118.       ball.SpeedX = maxSpeed;
  119.    }
  120.    else if(pad.right.edge.hitTest(ball.testMoveX,ball.testMoveY,true))
  121.    {
  122.       sndBallHitPadEdge.start(0,0);
  123.       _root.pad.right.edgeGlass.gotoAndPlay(1);
  124.       ball.SpeedX = - maxSpeed;
  125.    }
  126.    else
  127.    {
  128.       sndBallHitPad.start(0,0);
  129.       padMove = ball.SpeedX + padSpeed;
  130.       if(- maxSpeed >= padMove)
  131.       {
  132.          ball.SpeedX = - maxSpeed;
  133.       }
  134.       else if(padMove >= maxSpeed)
  135.       {
  136.          ball.SpeedX = maxSpeed;
  137.       }
  138.       else
  139.       {
  140.          ball.SpeedX = padMove;
  141.       }
  142.    }
  143.    if(0 >= ball.SpeedX && 0 >= ball.SpeedY)
  144.    {
  145.       ballBounce(ball,pad,"top","right");
  146.    }
  147.    else if(ball.SpeedX >= 0 && 0 >= ball.SpeedY)
  148.    {
  149.       ballBounce(ball,pad,"top","left");
  150.    }
  151. }
  152. pad.TargetX = 350;
  153. padKeyJump = 26;
  154. weaponFired = true;
  155. gotoAndPlay(66);
  156.